package scuff.msg.json.jackson

import scuff.msg.json.JsonMessageWriter
import scuff.msg.util.OutgoingMessage

import java.io.Writer

import com.fasterxml.jackson.databind.ObjectMapper

abstract class ReflectiveJacksonWriter[-PL <: AnyRef](mapper: ObjectMapper = new ObjectMapper) extends JsonMessageWriter[PL, Writer] {
  protected def serialize(msg: OutgoingMessage[PL], sink: Writer) = mapper.writeValue(sink, msg)
}